{{template "../layout/header.html" .}}
<!-- 内容主体区域 -->
<form class="layui-form" action="add.html" method="post">
<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
        <li class="layui-this">基本设置</li>
        <!--<li>用户管理</li>-->
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">

                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">选择角色</label>
                    <div class="layui-input-block">
                        {{range .Roledata}}
                        <input type="checkbox" name="role_ids[]" lay-skin="primary" value="{{.id}}" title="{{.role_name}}"><div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>{{.role_name}}</span><i class="layui-icon"></i></div>
                        {{end}}
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" name="username" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码框</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">密码不能包含root</div>
                </div>
                <!--<div class="layui-form-item">-->
                    <!--<label class="layui-form-label">选择框</label>-->
                    <!--<div class="layui-input-block">-->
                        <!--<select name="city" lay-verify="required">-->
                            <!--<option value=""></option>-->
                            <!--<option value="0">北京</option>-->
                            <!--<option value="1">上海</option>-->
                            <!--<option value="2">广州</option>-->
                            <!--<option value="3">深圳</option>-->
                            <!--<option value="4">杭州</option>-->
                        <!--</select>-->
                    <!--</div>-->
                <!--</div>-->
                <!--<div class="layui-form-item">-->
                    <!--<label class="layui-form-label">复选框</label>-->
                    <!--<div class="layui-input-block">-->
                        <!--<input type="checkbox" name="like[write]" title="写作">-->
                        <!--<input type="checkbox" name="like[read]" title="阅读" checked>-->
                        <!--<input type="checkbox" name="like[dai]" title="发呆">-->
                    <!--</div>-->
                <!--</div>-->
                <!--<div class="layui-form-item">-->
                    <!--<label class="layui-form-label">开关</label>-->
                    <!--<div class="layui-input-block">-->
                        <!--<input type="checkbox" name="switch" lay-skin="switch">-->
                    <!--</div>-->
                <!--</div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <input type="radio" name="sex" value="1" title="男">
                        <input type="radio" name="sex" value="2" title="女" checked>
                    </div>
                </div>
                <!--<div class="layui-form-item layui-form-text">-->
                    <!--<label class="layui-form-label">文本域</label>-->
                    <!--<div class="layui-input-block">-->
                        <!--<textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>-->
                    <!--</div>-->
                <!--</div>-->

            </div>
        <!--<div class="layui-tab-item">2</div>-->
    </div>
</div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="sub">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

{{template "../layout/commonjs.html" .}}
<script>
    //Demo
    layui.use(['form','layer','jquery'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        //监听提交
        form.on('submit(sub)', function(data){
            var form_data = $("form").serialize();
            var xsrftoken = $('meta[name=_xsrf]').attr('content');
            $.ajax({
                type: "post",
                url:'{{urlfor "AdminController.Add"}}',
                dataType: "json",
                data: form_data,
                headers : {'X-Xsrftoken':xsrftoken},
                success: function(out){
                    if (out.status == 0) {
                        layer.msg("操作成功",{icon: 1,time: 500},function () {
                            window.location.href="/admin/lst"
//                            window.location.reload()
                        })
                    } else {
                        layer.msg(out.message,{icon: 2,time: 500})
                    }
                },
                error: function(out){
                    layer.msg("未知错误",{icon: 2,time: 500})
                }

            });
            return false;
        });
    });
</script>

{{template "../layout/footer.html" .}}